package com.adcc.swingui.demo.toolbar.type;

import java.awt.Container;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenuItem;

import com.adcc.swingui.base.DefaultToolBar;
import com.jidesoft.swing.JideSplitButton;

/**
 * 带菜单复选工具
 * @author charlie
 *
 */
public class ToolBut4 extends DefaultToolBar {

	public ToolBut4(Container container) {
		super(container);
	}

	@Override
	protected JComponent build() {
		final JideSplitButton but = createSplitButton(new ImageIcon("res/images/waypoint.png"));
		but.setToolTipText("航路点");
		JCheckBoxMenuItem ndb = createCheckBoxMenuItem("NDB", "NDB");
		addChildItem(but, ndb, null);
		JCheckBoxMenuItem vor = createCheckBoxMenuItem("VOR", "VOR");
		addChildItem(but, vor, null);
		JCheckBoxMenuItem vorDme = createCheckBoxMenuItem("VOR/DME", "VOR/DME");
		addChildItem(but, vorDme, null);
		return but;
	}
	
	@Override
	protected void addMouseListener() {
		//这里填写对应响应事件
		JideSplitButton but = (JideSplitButton)sourceComp;
		//状态设置（业务填写）
		if(but.isSelected()) {
			but.setSelected(false);
		} else {
			but.setSelected(true);
		}
		//获取选中子菜单
		List<String> list = getSelectedItemName((JMenuItem[])but.getMenuComponents());
	}

	@Override
	protected void i18n() {
		// TODO Auto-generated method stub
		
	}

}
